/**
 * 用来实现lazyload
 */
package com.jz.aj;

import java.lang.reflect.Method;

import org.aspectj.lang.reflect.MethodSignature;

import com.jz.aspectj.annotation.Lazyload;


public aspect LazyloadAspectj extends LazyloadAspectSupport{
	protected pointcut lazyloadingMethod(Object model) : 
		execution(* com.jz.model..*.*(..)) && 
		@annotation(Lazyload) &&
		this(model);
	
	Object around(Object model) : lazyloadingMethod(model) {
		Object result = proceed(model);
		if (result != null) {
			return result;
		}
		MethodSignature methodSignature = (MethodSignature) thisJoinPoint.getSignature();
		Method method = methodSignature.getMethod();
		
		return loadObject(model, method);
	}
}
